package com.luo.controller;


import com.luo.pojo.Results;
import com.luo.service.IStudentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 学生信息表 前端控制器
 * </p>
 *
 * @author luo
 * @since 2025-06-22
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    private final IStudentService studentService;

    @Autowired
    public StudentController(IStudentService studentService) {
        this.studentService = studentService;
    }

    @ApiOperation("获取学生数量")
    @GetMapping("ClassSelectCount")
    public Results StudentSelectCount() {
        return Results.success(studentService.count( ));
    }

    @ApiOperation("平均年龄")
    @GetMapping("AvgAge")
    public Results AvgAge() {
        return Results.success(studentService.AvgAge());
    }

    @ApiOperation("查询班级人数")
    @GetMapping("CheckTheClassSize")
    public Results CheckTheClassSize() {
        return Results.success(studentService.CheckTheClassSize());
    }

    @ApiOperation("各性别人数")
    @GetMapping("CountBySex")
    public Results CountBySex() {
        return Results.success(studentService.CountBySex());
    }
}
